import 'package:flutter/material.dart';

/**
 * 导航页面
 */
class NavigatorDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FlatButton(
              child: Text('HOME'),
              onPressed: null,
            ),
            FlatButton(
              child: Text('About'),
              onPressed: () => {
                //跳转页面
                    Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) {
                        return PageDemo(title: 'Aboub');
                      },
                    )),
                  },
            ),
          ],
        ),
      ),
    );
  }
}

class PageDemo extends StatelessWidget {
  final String title;

  PageDemo({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
        elevation: 0.0,
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          //返回上一层页面
          Navigator.pop(context);
        },
        child: Icon(Icons.arrow_back),
      ),
    );
  }
}
